package com.kzj.common.result;

import com.kzj.common.constant.GlobalConstant;
import lombok.Data;

@Data
public class Result<T> {
    private String msg;
    private T data;
    // 1正确 0错误
    private Integer code;
    public static <T> Result<T> success(T obj)
    {
        Result<T> result = new Result<>();
        result.setCode(1);
        result.setData(obj);
        result.setMsg(GlobalConstant.OPERATE_SUCCESS);
        return result;
    }
    public static  Result<String> success()
    {
       return Result.successMsg(GlobalConstant.OPERATE_SUCCESS);
    }
    public static  Result<String> successMsg(String msg)
    {
       Result result=new Result();
       result.setCode(1);
       result.setMsg(msg);
       return result;
    }

    public static <T> Result<T> error(String msg)
    {
        Result<T> result = new Result<>();
        result.setCode(0);
        result.setMsg(msg);
        return result;
    }
}
